package com.wzy.Jdbc封装.controller;

import com.wzy.Jdbc封装.pojo.News_detail;
import com.wzy.Jdbc封装.service.Impl.option_News_detailImpl;
import com.wzy.Jdbc封装.service.option_News_detail;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

public class News_detailController {
    //注入服务层
    private static option_News_detail news_detail = new option_News_detailImpl();

    //根据id查询信息
    public static void select(News_detail detail)throws SQLException{
        List<News_detail> list = news_detail.selectById(detail);
        for (News_detail d : list){
            System.out.println(d.getId()+"-------"+ d.getCategoryId()+"-------"+d.getTitle()+"-------"+d.getSummary()+"-------"+d.getContent()+"-------"+d.getPicPath()+"-------"+d.getAuthor()+"-------"+d.getDate()+d.getDate1());
        }
    }

    //根据id删除信息
    public  static  void delete(News_detail detail) throws SQLException {
        int i = news_detail.deleteById(detail);
        System.out.println(i>0?"删除成功":"删除失败");
    }

    //根据id修改名称name
    public  static  void update(News_detail detail) throws SQLException {
        int i = news_detail.updateById(detail);
        System.out.println(i>0?"修改成功":"修改失败");
    }

    //新增信息
    public  static  void insert(News_detail detail) throws SQLException {
        int i = news_detail.insertNews(detail);
        System.out.println(i>0?"新增成功":"新增失败");
    }

}
